package com.example.widgetcase.slice;

import com.example.widget_lib.widget.HorScrollSelectedView;
import com.example.widgetcase.ResourceTable;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Text;

import java.util.ArrayList;
import java.util.List;

public class HorScrollSelecteViewAbility extends BaseSlice {
    @Override
    public int getChildUIContent() {
        return ResourceTable.Layout_horscroll_selectedview;
    }

    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);

        HorScrollSelectedView hssv = (HorScrollSelectedView) findComponentById(ResourceTable.Id_hssv);

        Text left = (Text) findComponentById(ResourceTable.Id_lftTv);
        Text right = (Text) findComponentById(ResourceTable.Id_rgtTv);
        left.setClickedListener(component -> hssv.setAnLeftOffset());
        right.setClickedListener(component -> hssv.setAnRightOffset());

        List<String> list = new ArrayList<>();
        list.add("abc");
        list.add("def");
        list.add("ccc");
        list.add("ddd");
        list.add("eee");
        list.add("fff");
        list.add("ggg");
        hssv.setData(list);
    }
}
